#include<algorithm>
#include<vector>
#include<iterator>
#include<fstream>
#include<map>
#include<iostream>
#include<string>

using namespace std;



int main(void)
{
	map<string,int> wordno ;
	map<string,int>::iterator mapiter;
	vector<string> vec;
	vector<int> No;
	vector<int>No2;
	ifstream in("F:\\DataSets\\TestSet.txt");
	string s;
	
	while(!in.eof())
	{
		in>>s;
		transform( s. begin(),s.end(),s.begin(),tolower);
		vec.push_back(s);
	}

	vec.pop_back();
	vector<string>::iterator iter=vec.erase(vec.begin());
	for(;iter!=vec.end();iter++)
	{
		wordno[*iter]++;
	}
	for(mapiter=wordno.begin();mapiter!=wordno.end();mapiter++)
	{
		No.push_back(mapiter->second);
	}

	make_heap(No.begin(),No.end());
	copy(No.begin(),No.end(),ostream_iterator<int>(cout," "));

	cout<<endl;
	for(int i=0;i<10;i++)
	{
		pop_heap(No.begin(),No.end()-i);
		No2.push_back(*(No.end()-i-1));
	}	

	for(mapiter=wordno.begin();mapiter!=wordno.end();mapiter++)
	{
		for(vector<int>::iterator iter=No2.begin();iter!=No2.end();iter++)
		{
			if(mapiter->second==*iter)
			{
				cout<<mapiter->first<<":"<<mapiter->second<<endl;
			}
		}
	}

}
	
